using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using IQIGame.Onigao.Framework;

namespace IQIGame.Onigao.GamePlay
{
    public static class FriendModuleExtensions
    {
        public static void SetOnline(ExText online, FriendData friendData)
        {
            if (friendData.online)
                online.text = "在线";
            else
            {
                int lastLoginTime = friendData.lastLoginTime;
                int offlineTime = (int)(GameServerModule.Instance.ServerTimeMillis / 1000) - lastLoginTime;
                if (offlineTime < 60)
                {
                    online.text = "最后在线: <1分钟";
                }
                else if (offlineTime >= 60 && offlineTime < 3600) // 60秒到1小时之间
                {
                    int minutes = offlineTime / 60;
                    online.text = $"最后在线: {minutes}分钟";
                }
                else if (offlineTime >= 3600 && offlineTime < 86400) // 1小时到1天之间
                {
                    int hours = offlineTime / 3600;
                    online.text = $"最后在线: {hours}小时";
                }
                else // 1天以上
                {
                    int days = offlineTime / 86400;
                    online.text = $"最后在线: {days}天";
                }


            }
        }
    }
}
